package com.xy.modulemain.model

import com.xy.baselibrary.base.MvvmBaseModel
import com.xy.modulemain.api.ApiService
import com.xy.modulemain.api.MainNetWorkApi
import com.xy.modulemain.lisener.IBaseModelListener
import com.xy.network.bean.ResponseBean
import com.xy.network.observer.BaseObserver

/**
 * @ClassName MainModel
 * @Author xy
 * @Date 2021/8/24 14:05
 * @Description 描述
 */
class MainModel : MvvmBaseModel<ResponseBean<MutableList<String>>>() {

    //上面的title
    override fun load() {

        MainNetWorkApi.getService(ApiService::class.java)
            ?.getTitles(15)
            ?.compose(MainNetWorkApi.instance.applySchedulers(object :
                BaseObserver<ResponseBean<MutableList<String>>>(this, this) { //线程切换，对错误信息进行监听
            })) //监听错误信息
    }

    override fun isPaging(): Boolean {
        return false
    }

    override fun onSuccess(t: ResponseBean<MutableList<String>>, isFromCache: Boolean) {
        notifyResultToListener(t,t,isFromCache)
    }

    override fun onFailure(e: Throwable) {

    }

}